home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / exec / funeleme.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  916 b   |  40 lines

  1. /*
  2. \fucref{fun\_element}{void fun\_element ()}
  3.     {}
  4.     {}
  5.     {xstrdup(), newvar()}
  6.     {}
  7.     {funeleme.c}
  8.     {
  9.  
  10.         This function is called when an {\em op\_element} opcode is enountered.
  11.         The last pushed value is interpreted as a list, the one but last pushed
  12.         value as an index.
  13.  
  14.         The return register {\em reg} is set to a string variable, holding a
  15.         duplicate of the listelement {\em index}. If index is larger than the
  16.         size of the element, {\em reg} holds a null-string.
  17.  
  18.     }
  19. */
  20.  
  21. #include "icm-exec.h"
  22.  
  23. void fun_element ()
  24. {
  25.     register unsigned
  26.         index;
  27.     register LIST_
  28.         *list;
  29.  
  30.     reg = newvar (e_str);
  31.  
  32.     index = (unsigned) stack [sp].vu.intval;
  33.     list  = &(stack [sp - 1].vu.i->ls.list);
  34.  
  35.     if (index < list->size )
  36.         reg.vu.i->ls.str = xstrdup (list->element [index]);
  37.     else
  38.         reg.vu.i->ls.str = xstrdup (nullstring);
  39. }
  40.